{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Solution(object):\n",
    "    def twoSum(self, numbers, target):\n",
    "        \"\"\"\n",
    "        :type numbers: List[int]\n",
    "        :type target: int\n",
    "        :rtype: List[int]\n",
    "        \"\"\"\n",
    "        min_num = numbers[0]\n",
    "        # right shift if min_num < 0\n",
    "        if min_num < 0:\n",
    "            # target should add double min_num\n",
    "            target = target - min_num*2\n",
    "            for i in range(len(numbers)):\n",
    "                numbers[i] = numbers[i] - min_num\n",
    "        # locate left pointer and right pointer\n",
    "        left = 0\n",
    "        for i in range(len(numbers)-1, 0, -1):\n",
    "            if numbers[i] > target:\n",
    "                continue\n",
    "            else:\n",
    "                right = i\n",
    "                break\n",
    "        while left < right:\n",
    "            two_sum = numbers[left] + numbers[right]\n",
    "            if two_sum == target:\n",
    "                return [left+1, right+1]\n",
    "            elif two_sum > target:\n",
    "                right = right - 1\n",
    "            elif two_sum < target:\n",
    "                left = left + 1\n",
    "        return"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = Solution()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 3]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.twoSum([-3,4,3,90], 0)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
